//@author A0105740R
package rightnow.parser.cmdline;

import java.util.List;

import rightnow.parser.cmdline.Token;
import rightnow.parser.cmdline.TokenType;

public class TokenListTestUtils {
	
	public static String getText(List<Token> tokenList) {
		StringBuilder sBd = new StringBuilder();
		for (Token token:tokenList) {
			if (token.getTokenType() == TokenType.TEXT) {
				sBd.append(token.getTokenString() + ' ');
			}
		}
		return sBd.toString();
	}
	
	public static void changeAllType(List<Token> tokenList, TokenType originType, TokenType targetType) {
		for (Token token:tokenList) {
			if (token.getTokenType() == originType) {
				token.setTokenType(targetType);
			}
		}
	}
	
	public static void printTokenStrOfTokenType(List<Token> tokenList, TokenType type) {
		int i = 0;
		for (Token token:tokenList) {
			if (token.getTokenType() == type) {
				System.out.println(i + " /" + token.getTokenString());
			}
			i++;
		}
	}
	
	public static void printTokenTypeList(List<Token> tokenList) {
		int i = 0;
		for (Token token:tokenList) {	
			System.out.print(i + " ");
			switch (token.getTokenType()) {
			case IDTF_AT:
				System.out.println("identifier at");
				break;
			case IDTF_BY:
				System.out.println("identifier by");
				break;
			case IDTF_ON:
				System.out.println("identifier on");
				break;
			case IDTF_START:
				System.out.println("identifier start");
				break;
			case DATE_MODF:
				System.out.println("date modifier");
				break;
			case STIME:
				System.out.println("start time");
				break;
			case ETIME:
				System.out.println("end time");
				break;
			case STD_DATE:
				System.out.println("standard date");
				break;
			case WEEKDAY:
				System.out.println("weekday");
				break;
			case TEXT:
				System.out.println("text");
				break;
			case UNDET:
				System.out.println("UNDET");
				break;
			default:
				break;
			}
			i++;
		}
	}
}
